package com.mgetwd.springbootweb.service.impl;

import cn.hutool.crypto.SecureUtil;
import com.mgetwd.springbootweb.dao.UserRepository;
import com.mgetwd.springbootweb.entities.User;
import com.mgetwd.springbootweb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class UserServiceImpl implements UserService {

    @Autowired //按照name注入
    private UserRepository userRepository;

    @Override
    public User selectUserByuserNameOrEmail(User user) {
        return userRepository.findUserByUsernameOrEmailAndPassword(user.getUsername(), SecureUtil.md5().digestHex(user.getPassword()));
    }
}
